const {defineConfig} = require('@vue/cli-service')
const path = require("path");
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')

module.exports = defineConfig({
    transpileDependencies: true,
    publicPath: '/pc',
    chainWebpack(config) {
        config.module
            .rule('svg')
            .exclude.add(path.resolve(__dirname, 'src/icon'))
            .end()
        config.module
            .rule('icon')
            .test(/\.svg$/)
            .include.add(path.resolve(__dirname, 'src/icon'))
            .end()
            .use('svg-sprite-loader')
            .loader('svg-sprite-loader')
            .options({
                symbolId: `icon-[name]`
            })
            .end()
    },
    devServer: {
        host: '127.0.0.1',
        proxy: {
            '/api': {
                changeOrigin: true,
                target: 'https://xiangmu.xinyunweb.com',
            },
            '/prod': {
                changeOrigin: true,
                target: 'https://xiangmu.xinyunweb.com',
                pathRewrite: {'^/prod': '/api'}
            },
        }
    },
    configureWebpack: {
        resolve: {
            fallback: {
                fs: false,
                crypto: require.resolve("crypto-browserify")
            }
        },
        plugins: [new NodePolyfillPlugin()]
    }
})
